package com.southgis.ibase.sql.config;

import java.sql.Connection;
import java.sql.SQLException;
import java.sql.SQLFeatureNotSupportedException;
import java.util.logging.Logger;

import javax.sql.DataSource;

/**基于Jndi数据源配置的封装类，主要解决在重启应用时，自动关闭Jndi数据源的问题。
 * @author LingJie
 * @version V1.0
 * @date 2021/3/12 11:40
 **/
public class JndiDataSourceWrapper implements DataSource{

    private DataSource delegete;

    public JndiDataSourceWrapper(DataSource delegete) {
        this.delegete = delegete;
    }

    @Override
    public Connection getConnection() throws SQLException {
        return delegete.getConnection();
    }

    @Override
    public Connection getConnection(String username, String password) throws SQLException {
        return delegete.getConnection(username, password);
    }

    @Override
    public java.io.PrintWriter getLogWriter() throws SQLException {
        return delegete.getLogWriter();
    }

    @Override
    public void setLogWriter(java.io.PrintWriter out) throws SQLException {
        delegete.setLogWriter(out);
    }

    @Override
    public void setLoginTimeout(int seconds) throws SQLException {
        delegete.setLoginTimeout(seconds);
    }

    @Override
    public int getLoginTimeout() throws SQLException {
        return delegete.getLoginTimeout();
    }

    @Override
    public Logger getParentLogger() throws SQLFeatureNotSupportedException {
        return delegete.getParentLogger();
    }

    @Override
    public <T> T unwrap(java.lang.Class<T> iface) throws java.sql.SQLException {
        return delegete.unwrap(iface);
    }

    @Override
    public boolean isWrapperFor(java.lang.Class<?> iface) throws java.sql.SQLException {
        return delegete.isWrapperFor(iface);
    }
}
